<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>LoveJob-商品新增</title>
    <link rel="stylesheet" href="media/layui/css/layui.css">
    <script type="application/javascript" src="media/js/jquery.min.js"></script>
    <script type="application/javascript" src="media/layui/layui.js"></script>
</head>
<body>
<div class="layui-container">
<div class="layui-row">
<div class="layui-col-lg-offset1 layui-col-lg9">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>商品新增</legend>
    </fieldset>
    <form class="layui-form" action="rolesave.do" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称：</label>
            <div class="layui-input-block">
                <input type="text" name="pname" lay-verify="required" placeholder="请输入名称……" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品类型：</label>
            <div class="layui-input-block">
                <select id="pt" name="ptid">
                    <option>--请选择类型--</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品品牌：</label>
            <div class="layui-input-block">
                <select id="pb" name="bid">
                    <option>--请选择品牌--</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品图片：</label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="test1">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                </button>
                <input type="hidden" name="imgs" id="pimg">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">新增商品</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
</div>
</div>
<script>
    layui.use(['form','upload'], function() {
        var form = layui.form;
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: 'http://localhost:8036/ossupload.do' //上传接口
            ,done: function(res){
                //上传完毕回调
                $("#pimg").val(res);
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>
</body>
</html>